const mysql = require('mysql');
const MySqlObj = {
    host:"localhost",
    user:"root",
    password:"",
    database:"vue3_study"
}

const pool = mysql.createPool(MySqlObj);
function sqlConnect(sql,arr,callback){
    pool.getConnection((err,connection)=>{
        if(err){
            console.log(err);
            return;
        }
        connection.query(sql,arr,(err,result)=>{
            //每次用完释放连接
            connection.release();
            if(err){
                console.log(err);
                return;
            }
            callback(result)
        })
    })
}
module.exports=sqlConnect